package Entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(schema="poleinfodb", name = "offer")
@Inheritance(strategy=InheritanceType.JOINED)
public class Offer implements Serializable {
	private static final long serialVersionUID = 42L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO) 
	private int id_Offer;
	
	//@OneToMany (mappedBy="offer")
	
	@Transient
	private Collection<Contract> contracts;
	
	public Offer( Collection<Contract> contracts) {
		super();
		this.contracts = contracts;
	}
	
	public Offer(){
		this.contracts = new ArrayList<Contract>();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_Offer;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Offer other = (Offer) obj;
		if (id_Offer != other.id_Offer)
			return false;
		return true;
	}


	@Override
	public String toString() {
		return "Offer [id_Offer=" + id_Offer + ", contracts=" + contracts + "]";
	}

	public int getId_Offer() {
		return id_Offer;
	}

	public void setId_Offer(int id_Offer) {
		this.id_Offer = id_Offer;
	}

	public Collection<Contract> getContracts() {
		return contracts;
	}

	public void setContracts(Collection<Contract> contracts) {
		this.contracts = contracts;
	}
}
